<!-- 项目经理 -->
<template>
  <div class='container'>
      <el-form :model="formData" ref="formData" label-width="150px">
         <el-row>
            <el-col :span="8">
                    <el-form-item
                        label="项目经理编码:"
                        prop="staffCode"
                    >
                        <el-input
                        placeholder="请输入内容"
                        v-model="formData.staffCode"
                        >
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item
                        label="项目经理名称:"
                        prop="staffName"
                    >
                        <el-input
                        placeholder="请输入内容"
                        v-model="formData.staffName"
                        >
                        </el-input>
                    </el-form-item>

                </el-col>
                <el-col :span="8">
                  <el-button type="primary" @click="cusrManagerQueryHandel" class="query-btn">查 询</el-button>
                </el-col>

            </el-row>
      </el-form>
       <DicTable
           ref="commonRegionTable"
            stripe
            max-height="500"
            highlight-current-row
            :columnData="proManagerColumns"
            :tableData="proManagerTableData"
            :loading="proManagerTableLoading"
            :currentPage="proManagerTablePage.pageIndex"
            :pageSize="proManagerTablePage.pageSize"
            :pager="true"
            :totalResult="parseInt(proManagerTablePage.rowCount)"
             @cell-click="proManagerCurrentChangeEvent"
            @on-page-change="proManagerHandlePageChange"
         >
        </DicTable>
  </div>
</template>

<script>
import DicTable from "@/components/public/DicTable";
import orderSevers from "@/api/order/AendFilling";
import { mapState, mapGetters, mapActions } from "vuex";
  export default {
    // import引入的组件需要注入到对象中才能使用
    components: {
      DicTable
    },
    // 这里存放数据
    data () {
      return {
          formData:{
            //   客户经理
            staffCode:"",
            staffName:""

          },
        selected:{
            name:"项目经理",
            staffCode:"",
            staffName:""
          },
        proManagerColumns: [
          { field: "staffCode", title: "客户经理编码" },
          { field: "staffName", title: "客户经理名称"}
      ],
      proManagerTableData: [],
      proManagerTableLoading: false,
      proManagerTablePage: {
        pageIndex: 1,
        pageSize: 10,
        rowCount: 0,
        pageCount: 0,
      },
      }
    },
    // 生命周期 - 创建完成（可以访问当前this实例）
    created () {
    },
    mounted () {
      this.getProManagerList();

    },
    // 方法集合
    methods: {
      async getProManagerList(){
        let params={
          "orgId":this.user.orgId,//ssion里取
          "postCode":"016_XMJLYWJL",//客户经理  014_KHJL    业务经理  016_XMJLYWJL
          "staffCode":this.formData.staffCode,
          "staffName":this.formData.staffName,
          "pageIndex":this.proManagerTablePage.pageIndex,
          "pageSize":this.proManagerTablePage.pageSize,
        }
        var result = await orderSevers.qryStaffList(params);
        if(result.meta.staffIdList){
          this.proManagerTableData=result.meta.staffIdList;
        }else{
           this.proManagerTableData=[];
        }
        this.proManagerTablePage.rowCount=result.meta.total;
      },

      cusrManagerQueryHandel(){
        this.proManagerTablePage.pageIndex=1;
        this.proManagerTablePage.pageSize=10;
        this.getProManagerList()
      },
       proManagerCurrentChangeEvent(){
        
        
        this.selected.staffCode=arguments[0].row.staffCode;
        this.selected.staffName=arguments[0].row.staffName;
        this.selected.staffId = arguments[0].row.staffId;
        this.$emit("clickRow",this.selected);
      },
      proManagerHandlePageChange(val){
         this.proManagerTablePage.pageIndex=val.currentPage;
        this.proManagerTablePage.pageSize=val.pageSize;
        this.getProManagerList()
      }
    },
    // 监听属性 类似于data概念
     computed: {
		...mapState("orders", ["orderItemList"]),
		...mapState("user", ["user"]),
  	},
    // 监控data中的数据变化
    watch: {},
    // 如果页面有keep-alive缓存功能，这个函数会触发
    activated () {},
    // 生命周期 - 挂载完成（可以访问DOM元素）
    beforeCreate () {},
    // 生命周期 - 数据挂载之前
    beforeMount () {},
    // 生命周期 - 数据更新之前
    beforeUpdate() {},
    // 生命周期 - 数据更新之后
    updated () {},
    // 生命周期 - 页面销毁之前
    beforeDestroy() {},
    // 生命周期 - 页面销毁完成
    destroyed () {},
  }
</script>

<style scoped>
  /* @import url(); 引入公共css类 */
.query-btn{
  margin-top:0.05rem;
}
</style>
